#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Solution
{
public:
    int numDecodings(string s)
    {
        if (s.size() == 1 && s[0] == '0') return 0;
        int n = s.size();
        vector<int> dp(n + 1, 0);
        dp[0] = 1;
        for (int i = 1; i <= n; i++)
        {
            if (s[i - 1] != '0') dp[i] += dp[i - 1];
            if (i - 2 >= 0 && s[i - 2] != '0')
            {
                std::string str(1, s[i - 1]);
                str = s[i - 2] + str;
                if (std::stoi(str) <= 26) dp[i] += dp[i - 2];
            }
        }
        return dp.back();
    }
};

int main()
{
    Solution s;
    s.numDecodings("12");
    return 0;
}